HAL PWR Functions

Wakeup pins management functions

group PWR_Exported_Functions_Group1

This section provides functions to manage the wakeup pins.

Functions

hal_status_t HAL_PWR_LP_SetConfigWakeupPin ( uint32_t wakeup_pin , const hal_pwr_wakeup_pin_config_t * p_config )

Set wakeup pin configuration.

Note

(*) : Not available on all devices.

Parameters :
Return values :
  • HAL_INVALID_PARAM – p_config pointer is NULL.

  • HAL_OK – Wakeup pin is configured correctly.

void HAL_PWR_LP_GetConfigWakeupPin ( uint32_t wakeup_pin , hal_pwr_wakeup_pin_config_t * p_config )

Get wakeup pin configuration.

Note

(*) : Not available on all devices.

Parameters :
void HAL_PWR_LP_EnableWakeupPin ( uint32_t wakeup_pin )

Enable the wakeup pin configuration.

Note

(*) : Not available on all devices.

Note

Wakeup pins are used to wake up the system from Standby mode.

Parameters :

wakeup_pin – This parameter can be one or a combination of PWR wakeup pin definitions.

void HAL_PWR_LP_DisableWakeupPin ( uint32_t wakeup_pin )

Disable the wakeup pin configuration.

Note

(*) : Not available on all devices.

Note

Wakeup pins are used to wake up the system from Standby mode.

Parameters :

wakeup_pin – This parameter can be one or a combination of PWR wakeup pin definitions.

hal_pwr_wakeup_pin_status_t HAL_PWR_LP_IsEnabledWakeupPin ( uint32_t wakeup_pin )

Check whether the wakeup pin is enabled.

Note

(*) : Not available on all devices.

Parameters :

wakeup_pin – This parameter can be one of PWR wakeup pin definitions.

Return values :

Wakeup – pin status

uint32_t HAL_PWR_LP_GetWakeupSource ( void )

Return the wakeup sources.

Note

(*) : Not available on all devices.

Warning

This API returns the wakeup source flags which can be a combination of multiple sources.

Return values :

Can – be one of or a combination of PWR wakeup source definitions.

void HAL_PWR_LP_CleanWakeupSource ( uint32_t wakeup_source )

Clean the selected wakeup source(s) flag(s).

Note

(*) : Not available on all devices.

Parameters :

wakeup_source – This parameter can be one or a combination of PWR wakeup source definitions.

RTC domain write protection management functions

group PWR_Exported_Functions_Group2

This section provides functions to manage RTC domain write protection:

Functions

void HAL_PWR_EnableRTCDomainWriteProtection ( void )

Enable the RTC domain write protection (RCC RTC domain control register RCC_BDCR, RTC registers, TAMP registers, backup registers and backup SRAM).

Note

After a system reset, the RTC domain is protected against possible unwanted write accesses.

void HAL_PWR_DisableRTCDomainWriteProtection ( void )

Disable the RTC domain write protection (RCC RTC domain control register RCC_BDCR, RTC registers, TAMP registers, backup registers and backup SRAM).

hal_pwr_rtc_domain_wrp_status_t HAL_PWR_IsEnabledRTCDomainWriteProtection ( void )

Check that RTC domain write protection is enabled.

Return values :

RTC – Domain write protection status

Low power mode management functions

group PWR_Exported_Functions_Group3

This section provides functions to manage low power modes:

Functions

void HAL_PWR_ClearCorePendingEvent ( void )

Clear core pending event.

Note

Clear the pending event to enter a given core into Sleep or stop mode with WFE entry.

Warning

Call this function just before APIs that enter Sleep and stop mode using a Wait For Event request.

void HAL_PWR_EnterSleepMode ( hal_pwr_low_pwr_mode_entry_t sleep_entry )

Enter the core into sleep mode.

Parameters :

sleep_entry – Parameter of the hal_pwr_low_pwr_mode_entry_t enumeration.

void HAL_PWR_EnterStopMode ( hal_pwr_low_pwr_mode_entry_t stop_entry , hal_pwr_stop_mode_t stop_mode )

Enter the MCU in stop mode.

Parameters :
void HAL_PWR_EnterStandbyMode ( void )

Enter the MCU in Standby mode.

void HAL_PWR_SetCoreSleepMode ( hal_pwr_core_sleep_mode_t sleep_mode )

Set the core sleep mode configuration.

Parameters :

sleep_mode – This parameter is an element of hal_pwr_core_sleep_mode_t enumeration.

hal_pwr_core_sleep_mode_t HAL_PWR_GetCoreSleepMode ( void )

Get the core sleep mode configuration.

Return values :
  • HAL_PWR_CORE_SLEEP – Core sleep mode.

  • HAL_PWR_CORE_DEEP_SLEEP – Core deep sleep mode.

void HAL_PWR_EnableCoreSleepOnExit ( void )

Enable SLEEP-ON-EXIT feature when returning from handler mode to thread mode.

void HAL_PWR_DisableCoreSleepOnExit ( void )

Disable SLEEP-ON-EXIT feature when returning from handler mode to thread mode.

hal_pwr_core_sleep_on_exit_status_t HAL_PWR_IsEnabledCoreSleepOnExit ( void )

Check whether core SLEEP-ON-EXIT is enabled.

Return values :

hal_pwr_core_sleep_on_exit_status_t – Core sleep-on-exit status.

void HAL_PWR_EnableCoreSendEventOnPending ( void )

Enable core Send Event On Pending feature.

void HAL_PWR_DisableCoreSendEventOnPending ( void )

Disable core Send Event On Pending.

hal_pwr_core_sev_on_pending_status_t HAL_PWR_IsEnabledCoreSendEventOnPending ( void )

Get core Send Event On Pending status.

Return values :
  • HAL_PWR_CORE_SEV_ON_PENDING_DISABLED – Core send event on pending disabled.

  • HAL_PWR_CORE_SEV_ON_PENDING_ENABLED – Core send event on pending enabled.

hal_pwr_system_mode_t HAL_PWR_GetPreviousSystemPowerMode ( void )

Get the previous system power mode.

Note

Sleep mode is an ARM core mode and not a system power mode as it does not affect system clock on return from sleep, so it is not reported by this function.

Warning

This function is expected to be called on return from low power mode so to take the necessary actions such as re-enabling clocks automatically disabled during low power mode.

Return values :

hal_pwr_system_mode_t – Previous power mode.

void HAL_PWR_CleanPreviousSystemPowerMode ( void )

Clean the previous system power mode flags.

Note

This function must be called before entering in low power mode to ensure that HAL_PWR_GetPreviousSystemPowerMode() will return the right information on return from low power mode.

Warning

This function clears both standby and stop flags.

Voltage monitoring management functions

group PWR_Exported_Functions_Group4

This section provides functions to manage voltage monitoring.

Functions

void HAL_PWR_EnableProgrammableVoltageDetector ( void )

Enable the voltage threshold detection by the programmable voltage detector (PVD).

void HAL_PWR_DisableProgrammableVoltageDetector ( void )

Disable the voltage threshold detection by the programmable voltage detector (PVD).

hal_pwr_pvd_status_t HAL_PWR_IsEnabledProgrammableVoltageDetector ( void )

Check whether the programmable voltage detection is enabled.

Return values :
  • HAL_PWR_PVD_DISABLED – Programmable voltage detection disabled.

  • HAL_PWR_PVD_ENABLED – Programmable voltage detection enabled.

hal_pwr_pvd_out_t HAL_PWR_GetProgrammableVoltageDetectorOutput ( void )

Provide the current PVD output.

Return values :
  • HAL_PWR_PVD_OUT_EQ_HIGH_THR – VDD is equal or higher than programmable voltage detector threshold.

  • HAL_PWR_PVD_OUT_LOW_THR – VDD is lower than programmable voltage detector threshold.

Memory retention management functions

group PWR_Exported_Functions_Group5

This section provides functions to manage memory content retention.

Note

(*) : Not available on all devices.

Functions

hal_status_t HAL_PWR_LP_EnableMemoryRetention ( hal_pwr_memory_retention_t memory )

Enable memory retention in stop mode.

Parameters :

memory – This parameter is an element of hal_pwr_memory_retention_t enumeration.

Return values :
  • HAL_OK – Memory retention has been correctly enabled.

  • HAL_INVALID_PARAM – The selected memory does not exist while USE_HAL_CHECK_PARAM is used.

  • HAL_ERROR – Selected memory is paginated, use HAL_PWR_LP_EnableMemoryPageRetention().

hal_status_t HAL_PWR_LP_DisableMemoryRetention ( hal_pwr_memory_retention_t memory )

Disable memory retention in stop mode.

Parameters :

memory – This parameter is an element of hal_pwr_memory_retention_t enumeration.

Return values :
  • HAL_OK – Memory retention has been correctly disabled.

  • HAL_INVALID_PARAM – The selected memory does not exist while USE_HAL_CHECK_PARAM is used.

  • HAL_ERROR – Selected memory is paginated, use HAL_PWR_LP_DisableMemoryPageRetention().

hal_pwr_memory_retention_status_t HAL_PWR_LP_IsEnabledMemoryRetention ( hal_pwr_memory_retention_t memory )

Get memory retention status.

Note

If the ASSERT are disabled, HAL_PWR_MEMORY_RETENTION_DISABLED is returned for paginated memories.

Parameters :

memory – This parameter is an element of hal_pwr_memory_retention_t enumeration.

Return values :
  • HAL_PWR_MEMORY_RETENTION_DISABLED – if the selected memory is not retained in stop mode or if the selected memory does not exist while USE_HAL_CHECK_PARAM is used.

  • HAL_PWR_MEMORY_RETENTION_ENABLED – if the selected memory is retained in stop mode.

hal_status_t HAL_PWR_LP_EnableMemoryPageRetention ( hal_pwr_memory_retention_t memory , uint32_t page_idx , uint32_t page_nbr )

Enable memory page retention in stop mode.

Parameters :
  • memory – This parameter is an element of hal_pwr_memory_retention_t enumeration.

  • page_idx – the index of memory page (starting from 1).

  • page_nbr – The memory pages number.

Return values :
  • HAL_OK – Memory page retention has been correctly enabled.

  • HAL_INVALID_PARAM – The selected memory does not exist, the page index is out of range or the selected number of pages does not fit the memory.

  • HAL_ERROR – Memory page retention could not be enabled, the selected memory is not paginated.

hal_status_t HAL_PWR_LP_DisableMemoryPageRetention ( hal_pwr_memory_retention_t memory , uint32_t page_idx , uint32_t page_nbr )

Disable memory page retention in stop mode.

Parameters :
  • memory – This parameter is an element of hal_pwr_memory_retention_t enumeration.

  • page_idx – the index of memory page (starting from 1).

  • page_nbr – The memory pages number.

Return values :
  • HAL_OK – Memory page retention has been correctly disabled.

  • HAL_INVALID_PARAM – The selected memory does not exist, the page index is out of range or the selected number of pages does not fit the memory.

  • HAL_ERROR – Memory page retention could not be disabled, the selected memory is not paginated.

hal_pwr_memory_page_retention_status_t HAL_PWR_LP_IsEnabledMemoryPageRetention ( hal_pwr_memory_retention_t memory , uint32_t page_idx )

Check the selected memory page retention in stop mode status.

Note

If the ASSERT are disabled, HAL_PWR_MEMORY_PAGE_RETENTION_DISABLED is returned for out-of-range pages or non-paginated memories.

Parameters :
  • memory – This parameter is an element of hal_pwr_memory_retention_t enumeration.

  • page_idx – the index of memory page (starting from 1).

Return values :
  • HAL_PWR_MEMORY_PAGE_RETENTION_DISABLED – if the selected memory page is not retained in stop mode or if the selected memory does not exist while USE_HAL_CHECK_PARAM is used.

  • HAL_PWR_MEMORY_PAGE_RETENTION_ENABLED – if the selected memory page is retained in stop mode.

Memory management functions

group PWR_Exported_Functions_Group6

This section provides functions to manage flash memory low power modes.

Functions

void HAL_PWR_LP_EnableFlashLowPWRMode ( void )

Enable the flash low power mode.

void HAL_PWR_LP_DisableFlashLowPWRMode ( void )

Disable the flash low power mode.

hal_pwr_flash_low_pwr_mode_status_t HAL_PWR_LP_IsEnabledFlashLowPWRMode ( void )

Check whether the flash low power mode is enabled.

Return values :

hal_pwr_Flash_low_pwr_mode_status_t – Flash low power mode status.

I/O retention management functions

group PWR_Exported_Functions_Group7

This section provides functions to manage I/O retention in low power mode.

Functions

void HAL_PWR_LP_EnableIORetention ( hal_pwr_io_retention_t io )

Enable the IO retention in Standby mode.

Note

The output is sampled and applied to the output I/O during Standby mode.

Parameters :

io – This parameter is an element or combination of elements of hal_pwr_io_retention_t enumeration.

void HAL_PWR_LP_DisableIORetention ( hal_pwr_io_retention_t io )

Disable the IO retention in Standby mode.

Parameters :

io – This parameter is an element of hal_pwr_io_retention_t enumeration.

hal_pwr_io_retention_status_t HAL_PWR_LP_IsEnabledIORetention ( hal_pwr_io_retention_t io )

Check whether I/O retention in Standby mode is enabled.

Parameters :

io – This parameter is an element of hal_pwr_io_retention_t enumeration.

Return values :

hal_pwr_io_retention_status_t – The I/O retention status.

Privilege management functions

group PWR_Exported_Functions_Group8

This section provides functions to manage privilege attributes.

Functions

hal_status_t HAL_PWR_SetPrivAttr ( uint32_t item , hal_pwr_priv_attr_t priv_attr )

Set privilege attribute.

Parameters :
Return values :
  • HAL_ERROR – The function is called in unprivileged mode.

  • HAL_OK – Privilege attribute has been correctly set.

hal_pwr_priv_attr_t HAL_PWR_GetPrivAttr ( uint32_t item )

Get privilege attribute.

Parameters :

item – The item attribute to be queried.

Return values :

hal_pwr_priv_attr_t – This parameter is an element of hal_pwr_priv_attr_t enumeration.